package zjut.cocouml.command;

import org.eclipse.gef.commands.Command;

import zjut.cocouml.model.BMethod;

public class BMethodModifyCommand extends Command{
	
	public void execute() {
		
		this.oldMethodName = model.getMethodName();
		this.oldAccessAuthrity = model.getAccessAuthrity();
		this.oldType = model.getReturnType();
		this.oldParamters = model.getParamters();
		this.oldFinal = model.isFinal();
		this.oldStatic = model.isStatic();
		this.oldAbstract = model.isAbstract();
		
		model.setMethodName(newMethodName);
		model.setAccessAuthrity(newAccessAuthrity);
		model.setReturnType(newType);
		model.setParamters(newParamters);
		model.setFinal(newFinal);
		model.setAbstract(newAbstract);
		model.setStatic(newStatic);
		
		this.model.setDisplayName(model.getDisplayName());
		
	}
	
	public void undo() {
		model.setMethodName(oldMethodName);
		model.setAccessAuthrity(oldAccessAuthrity);
		model.setReturnType(oldType);
		model.setParamters(oldParamters);
		model.setFinal(oldFinal);
		model.setAbstract(oldAbstract);
		model.setStatic(oldStatic);
		
		this.model.setDisplayName(model.getDisplayName());
	}
	
	private BMethod model;
	
	private String oldMethodName;
	private String newMethodName;
	
	private String oldAccessAuthrity;
	private String newAccessAuthrity;
	
	private String oldType;
	private String newType;

	private String oldParamters;
	private String newParamters;
	
	private boolean oldFinal;
	private boolean newFinal;
	
	private boolean oldStatic;
	private boolean newStatic;
	
	private boolean oldAbstract;
	private boolean newAbstract;
	
	public void setModel(BMethod model) {
		this.model = model;
	}

	public void setNewMethodName(String newMethodName) {
		this.newMethodName = newMethodName;
	}

	public void setNewAccessAuthrity(String newAccessAuthrity) {
		this.newAccessAuthrity = newAccessAuthrity;
	}

	public void setNewType(String newType) {
		this.newType = newType;
	}

	public void setNewParamters(String newParamters) {
		this.newParamters = newParamters;
	}

	public void setNewFinal(boolean newFinal) {
		this.newFinal = newFinal;
	}

	public void setNewStatic(boolean newStatic) {
		this.newStatic = newStatic;
	}

	public void setNewAbstract(boolean newAbstract) {
		this.newAbstract = newAbstract;
	}
}
